(function ($) {
  Drupal.behaviors.ffs2014 = {
    attach: function (context) {
      $(window).load(function(){
        jQuery('.form-item label').matchWidths();
      });
    }
  };
  $.fn.matchHeights = function (settings) {
    settings = jQuery.extend(this, {
      minHeight: null,
      maxHeight: null
    }, settings);
    tallest = settings.minHeight ? settings.minHeight : 0;
    this.each(function () {
      if ($(this).innerHeight() > tallest) {
        tallest = $(this).outerHeight()
      }
    });
    if (settings.maxHeight && tallest > settings.maxHeight) {
      tallest = settings.maxHeight;
    }
    return this.each(function () {
      extra = $(this).innerHeight() - $(this).height();
      extra += $(this).outerHeight() - $(this).innerHeight();
      $.browser.msie && $.browser.version == 6 || settings.maxHeight ? $(this).css({
        height: tallest - extra
      }) : $(this).css({
        "min-height": tallest - extra
      })
    })
  }
  $.fn.matchWidths = function (settings) {
    settings = jQuery.extend(this, {
      minWidth: null,
      maxWidth: null
    }, settings);
    tallest = settings.minWidth ? settings.minWidth : 0;
    this.each(function () {
      if ($(this).innerWidth() > tallest) {
        tallest = $(this).outerWidth()
      }
    });
    if (settings.maxWidth && tallest > settings.maxWidth) {
      tallest = settings.maxWidth;
    }
    return this.each(function () {
      extra = $(this).innerWidth() - $(this).width();
      extra += $(this).outerWidth() - $(this).innerWidth();
      $.browser.msie && $.browser.version == 6 || settings.maxWidth ? $(this).css({
        height: tallest - extra
      }) : $(this).css({
        "min-width": tallest - extra
      })
    })
  }
})(jQuery);
